﻿using System;
using Zeus.Thunder.Core;
using CsharpTrainer.MongoDB.Model;
using CsharpTrainer.MongoDB.DAL;

namespace SharpTrainer.MongoDB
{
    class MongoUpdateSingleTest : ITestCase
    {
        public void Run()
        {
            MongodbHelper<CsharpTrainer.MongoDB.Model.Person> helper = new MongodbHelper<CsharpTrainer.MongoDB.Model.Person>();

            //修改jack144改成peter
            var person = helper.Single(i => i.Name == "jack144");
            if (person != null)
            {
                person.Name = "peter";
                helper.Update(person, i => i.ID == person.ID);
                Console.WriteLine("Update Successful!");

                Console.WriteLine("New Person Info:");

                person = helper.Single(a => a.Name == "peter");
                Console.WriteLine(person);
            }
            else
            {
                Console.WriteLine("No this person!");
            }
        }
    }
}
